package fifth;

public class TestCircleWithStaticMembers {
    public static void main(String[] args) {
        System.out.println("Before creating objects");
        System.out.println("The number of Circle object is "+Circletest.numerOfObjects);

        Circletest c1= new Circletest();
        System.out.println("\nAfter creating c1");
        System.out.println("c1 : radius (" +c1.radius +") and number of Circle objects ("+c1.numerOfObjects+")");

        Circletest c2 = new Circletest(5);
        c1.radius=9;   //  static  int  numerOfObjects 是共用变量，c1,c2都可以改变

        System.out.println("\nAfter creating c2 and modifying c1");
        System.out.println("c1 : radius (" +c1.radius +") and number of Circle objects ("+c1.numerOfObjects+")");
        System.out.println("c2 : radius (" +c2.radius +") and number of Circle objects ("+c2.numerOfObjects+")");

    }


}
class Circletest{
    double radius;
    static  int  numerOfObjects = 0;

    Circletest(){
        radius =1;
        numerOfObjects++;
    }
    Circletest(double newRadius){
        radius = newRadius;
        numerOfObjects++;
    }

    static  int getNumerOfObjects(){
        return numerOfObjects;
    }
    double getArea(){
        return radius * radius * Math.PI;
    }


}
